package com.tanjun.userservice.web.controller.inner;

import com.tanjun.common.model.R;
import com.tanjun.userservice.apiservice.api.AdminMenuApi;
import com.tanjun.userservice.apiservice.response.adminmenu.admin.AdminMenuResponse;
import com.tanjun.userservice.web.biz.api.AdminMenuApiBiz;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.tanjun.common.constants.UrlConstant.URL_AUTH.OPEN;
import static com.tanjun.common.constants.UrlConstant.URL_USER.INNER;

@RestController
@RequestMapping(INNER+"/adminMenu")
@Slf4j
public class InnerBaseAdminMenuController implements AdminMenuApi {
    @Autowired
    private AdminMenuApiBiz adminMenuBiz;


    /**
     * 根据角色id获取用户对应的菜单
     *
     * @param roleIds 角色id
     * @return 菜单
     */
    @Override
    @PostMapping(OPEN+"/getRolesMenu")
    public R<List<AdminMenuResponse>> getRolesMenus(@RequestBody List<Long> roleIds) {
        return R.OK(adminMenuBiz.getMenusByRoleIds(roleIds));
    }

}
